﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Peter.Common.Controls"
                    xmlns:icons="clr-namespace:Peter.Common.Icons">

   <!-- Control Templates for Numeric Spinner Control-->
   <Style TargetType="RepeatButton"
          x:Key="RepeatButtonStyle">
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="RepeatButton">
               <Grid>
                  <Border Background="{DynamicResource SecondaryBrush}"
                          x:Name="PART_MainBorder" />
                  <ContentPresenter Content="{TemplateBinding Content}"
                                    VerticalAlignment="Center"
                                    Margin="2,3" />
                  <Border BorderThickness="1"
                          BorderBrush="{DynamicResource MainBorderBrush}" />
               </Grid>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsMouseOver"
                           Value="True">
                     <Setter TargetName="PART_MainBorder"
                             Property="Background"
                             Value="{DynamicResource SecondaryHoverBrush}" />
                  </Trigger>
                  <Trigger Property="IsPressed"
                           Value="True">
                     <Setter TargetName="PART_MainBorder"
                             Property="Background"
                             Value="{DynamicResource SecondaryClickBrush}" />
                  </Trigger>
                  <Trigger Property="IsEnabled"
                           Value="False">
                     <Setter TargetName="PART_MainBorder"
                             Property="Background"
                             Value="{DynamicResource DisabledBackgroundBrush}" />
                     <Setter Property="Foreground"
                             Value="{DynamicResource DisabledForegroundBrush}" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="{x:Type controls:NumericUpDown}">
      <Setter Property="Height"
              Value="25" />
      <Setter Property="BorderThickness"
              Value="0,1,0,1" />
      <Setter Property="FontSize"
              Value="14" />
      <Setter Property="FontFamily"
              Value="Segoe UI" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type controls:NumericUpDown}">
               <Grid>
                  <VisualStateManager.VisualStateGroups>
                     <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused">
                           <Storyboard>
                              <DoubleAnimation BeginTime="00:00:00.000"
                                               Duration="00:00:00.300"
                                               From="0"
                                               To="1"
                                               Storyboard.TargetProperty="Opacity"
                                               Storyboard.TargetName="PART_TextBoxGlowBorder" />
                              <DoubleAnimation BeginTime="00:00:00.000"
                                               Duration="00:00:00.300"
                                               From="0"
                                               To="1"
                                               Storyboard.TargetProperty="Opacity"
                                               Storyboard.TargetName="PART_TextBoxOverlayBorder" />
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unfocused">
                           <Storyboard>
                              <DoubleAnimation BeginTime="00:00:00.000"
                                               Duration="00:00:00.700"
                                               From="1"
                                               To="0"
                                               Storyboard.TargetProperty="Opacity"
                                               Storyboard.TargetName="PART_TextBoxGlowBorder" />
                              <DoubleAnimation BeginTime="00:00:00.000"
                                               Duration="00:00:00.700"
                                               From="1"
                                               To="0"
                                               Storyboard.TargetProperty="Opacity"
                                               Storyboard.TargetName="PART_TextBoxOverlayBorder" />
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                     <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal">
                           <Storyboard>
                              <DoubleAnimation BeginTime="00:00:00.000"
                                               Duration="00:00:00.700"
                                               From="1"
                                               To="0"
                                               Storyboard.TargetProperty="Opacity"
                                               Storyboard.TargetName="PART_TextBoxHoverBorder" />
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="MouseOver">
                           <Storyboard>
                              <DoubleAnimation BeginTime="00:00:00.000"
                                               Duration="00:00:00.300"
                                               From="0"
                                               To="1"
                                               Storyboard.TargetProperty="Opacity"
                                               Storyboard.TargetName="PART_TextBoxHoverBorder" />
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                           <Storyboard>
                              <ColorAnimation Storyboard.TargetName="PART_ContentBorder"
                                              Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                                              To="{DynamicResource DisabledBackgroundColor}"
                                              Duration="0:0:0.25" />
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="ReadOnly">
                           <Storyboard>
                              <ColorAnimation Storyboard.TargetName="PART_ContentBorder"
                                              Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                                              To="{DynamicResource SecondaryColor}"
                                              Duration="0:0:0.25" />
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>

                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="Auto" />
                     <ColumnDefinition Width="Auto" />
                     <ColumnDefinition Width="Auto" />
                     <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>

                  <!-- Decrement Button -->
                  <RepeatButton Width="30"
                                Grid.Column="0"
                                Focusable="False"
                                x:Name="PART_DecrementButton"
                                Style="{StaticResource RepeatButtonStyle}">
                     <RepeatButton.Content>
                        <icons:IconDisplay Icon="Minus"
                                           IconSize="Smallest" />
                     </RepeatButton.Content>
                  </RepeatButton>

                  <Grid Grid.Column="1"
                        MinWidth="50">
                     <Border Padding="4"
                             x:Name="PART_ContentBorder"
                             Background="{DynamicResource BackgroundBrush}">
                        <ScrollViewer x:Name="PART_ContentHost"
                                      VerticalScrollBarVisibility="Hidden"
                                      HorizontalScrollBarVisibility="Hidden" />
                     </Border>
                     <Border x:Name="PART_TextBoxBorder"
                             BorderThickness="{TemplateBinding BorderThickness}"
                             BorderBrush="{DynamicResource MainBorderBrush}" />
                     <Border x:Name="PART_TextBoxHoverBorder"
                             Opacity="0.0"
                             BorderThickness="1"
                             BorderBrush="{DynamicResource TextBoxHighlightBrush}" />
                     <Border x:Name="PART_TextBoxOverlayBorder"
                             Opacity="0.0"
                             BorderThickness="1"
                             BorderBrush="{DynamicResource TextBoxHighlightBrush}" />
                     <Border Opacity="0.0"
                             BorderThickness="1"
                             x:Name="PART_TextBoxGlowBorder"
                             BorderBrush="{DynamicResource TextBoxHighlightBrush}">
                        <Border.Effect>
                           <BlurEffect Radius="5" />
                        </Border.Effect>
                     </Border>
                  </Grid>

                  <!-- Increment Button -->
                  <RepeatButton Width="30"
                                Grid.Column="2"
                                Focusable="False"
                                x:Name="PART_IncrementButton"
                                Style="{StaticResource RepeatButtonStyle}">
                     <RepeatButton.Content>
                        <icons:IconDisplay Icon="Plus"
                                           IconSize="Smallest" />
                     </RepeatButton.Content>
                  </RepeatButton>

                  <Border Grid.Column="3"
                          Padding="10,0"
                          Background="{DynamicResource SecondaryBrush}"
                          BorderBrush="{DynamicResource MainBorderBrush}"
                          BorderThickness="0,1,1,1"
                          x:Name="PART_Label">
                     <TextBlock Text="{TemplateBinding Label}"
                                VerticalAlignment="Center" />
                  </Border>
               </Grid>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsSpinnerShown"
                           Value="False">
                     <Setter TargetName="PART_IncrementButton"
                             Property="Visibility"
                             Value="Collapsed" />
                     <Setter TargetName="PART_DecrementButton"
                             Property="Visibility"
                             Value="Collapsed" />
                  </Trigger>
                  
                  <Trigger Property="HasLabel"
                           Value="False">
                     <Setter TargetName="PART_Label"
                             Property="Visibility"
                             Value="Collapsed" />
                  </Trigger>

                  <Trigger Property="IsEnabled"
                           Value="False">
                     <Setter Property="Foreground"
                             Value="{DynamicResource DisabledForegroundBrush}" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

</ResourceDictionary>